package com.douyin.controller;


import com.douyin.dto.PageActionsDTO;
import com.douyin.dto.Result;
import com.douyin.service.IFollowService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 用户关注关系表 前端控制器
 * </p>
 *
 * @author k
 * @since 2025-07-27
 */
@Slf4j
@RestController
@RequestMapping("/follows")
public class FollowsController {
    @Autowired
    IFollowService followsService;

    /**
     * 用户关注或取消关注
     * @param followUserId
     * @return
     */
    @PutMapping("/{followUserId}")
    public Result userFollow(@PathVariable Long followUserId){
        log.info("用户关注或取消关注");
        return followsService.userFollow(followUserId);
    }

    /**
     * 获取正在关注的用户列表
     * @param pageActionsDTO
     * @return
     */
    @GetMapping("/following")
    public Result getFollowingList(@RequestBody PageActionsDTO pageActionsDTO){
        log.info("获取正在关注的用户列表");
        return followsService.getFollowings(pageActionsDTO);
    }

    /**
     * 获取粉丝列表
     * @param pageActionsDTO
     * @return
     */
    @GetMapping("/followers")
    public Result getFollowersList(@RequestBody PageActionsDTO pageActionsDTO){
        log.info("获取粉丝列表");
        return followsService.getFollowers(pageActionsDTO);
    }

}

